package example.controller;

import example.utils.ResultData;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestController;

@RestController
@ControllerAdvice
public class BadRequestController {

    @ExceptionHandler(RuntimeException.class)
    public final ResultData badRequest(RuntimeException ex) {
        String message = ex.getMessage();
        System.out.println(message);
        return ResultData.fail(message);
    }
}
